package jpao.benchmark;

/**
 *
 * @author soa
 */
public class BenchmarkHelper {

    public static TpsMonitor singleThreadBenchmark(final BenchmarkWorker worker, final long loopCount) {
        // benchmark
        TpsMonitor tc = new TpsMonitor();
        tc.start();
        for (int i = 0; i < loopCount; i++) {
            try {
                worker.work();
            } catch (Exception e) {
                tc.incrementErrorCount();
                System.err.println(e.getMessage());
            } finally {
                tc.increment();
            }
        }
        tc.stop();
        return tc;
    }
}
